public class Fibon {
    //递归算法
    public static int FibRecursive(int n){
        if(n == 0 ){
            return 0;
        }
        if(n == 1){
            return 1;
        }
        return FibRecursive(n-1)+FibRecursive(n-2);
    }
    //循环算法
    public static int Fib2(int n){
        if(n == 0 ){
            return 0;
        }
        if(n == 1){
            return 1;
        }
        int a=0;
        int b=1;
        int result = 0;
        for (int i = 1; i < n; i++) {
            result = a+b;
            a = b;
            b = result;
        }
        return result;
    }
    public static void main1(String[] args){
        System.out.println(FibRecursive(3));
        System.out.println(Fib2(4));
    }
}
